package com.neuedu.nevserver.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.neuedu.nevserver.dto.NodeInfoTypeDTO;
import com.neuedu.nevserver.pojo.NodeInfo;
import com.neuedu.nevserver.service.NodeInfoService;
import com.neuedu.nevserver.vo.NodeInfoTypeVO;
import com.neuedu.nevserver.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sjy
 * @since 2025-03-18
 */
@RestController
@RequestMapping("/node-info")
@Api(tags="流通节点管理",description = "提供流通节点管理API接口")
public class NodeInfoController {

    @Autowired
    private NodeInfoService nodeInfoService;

    @GetMapping("/nodeLogin")
    @ApiOperation("流通节点登录接口")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "string",name = "code", value = "登录编码",required =true),
            @ApiImplicitParam(dataType = "string",name = "password", value = "登录密码",required =true),
    })
    public ResultVO<NodeInfo> nodeLogin(String code,String password) throws Exception {
        return nodeInfoService.nodeLogin(code,password);
    }

    @ApiOperation("流通节点注册接口")
    @PostMapping("/registerNode")
    public ResultVO registerNode(NodeInfo nodeInfo) throws Exception {
        return nodeInfoService.nodeRegister(nodeInfo);
    }

    @ApiOperation("流通节点查询接口")
    @GetMapping("/listNode")
    public ResultVO<List<NodeInfo>> listNode(NodeInfo nodeInfo) throws Exception {
        return nodeInfoService.listNode(nodeInfo);
    }

    @ApiOperation("分页查询流通节点信息及其企业类型信息")
    @GetMapping("/pageNodeInfoAndType")
    public ResultVO<IPage<NodeInfoTypeVO>> pageNodeInfoAndType(NodeInfoTypeDTO nodeInfoTypeDTO)throws Exception {
        return nodeInfoService.pageNodeInfoType(nodeInfoTypeDTO);
    }
}
